package com.LeeCode;

import java.util.ArrayList;
import java.util.List;

/**
 * 最长相邻不相等子序列 I
 */

public class Code2900 {
    public static void main(String[] args) {
        String[] words = {"e", "a", "b"};
        int[] groups = {0, 0, 1};
        System.out.println(new Code2900().getLongestSubsequence(words, groups));
    }

    public List<String> getLongestSubsequence(String[] words, int[] groups) {
        List<String> ans = new ArrayList<>();
        int len = words.length;
        for (int i = 0; i < len; i++) {
            if (i == len - 1 || groups[i] != groups[i + 1]) {
                ans.add(words[i]);
            }
        }
        return ans;
    }
}
